package com.plata.base.aclr.utils;

import android.database.Cursor;
import android.os.ParcelFileDescriptor;

import java.io.Closeable;

public class IOUtils {

    private static final String TAG = "IOUtils";

    public static void closeSilently(Closeable c) {
        try {
            if (c != null) {
                c.close();
            }
        } catch (Throwable t) {
            LogTool.w(TAG, "closeSilently. fail to close.", t);
        }
    }

    public static void closeSilently(ParcelFileDescriptor p) {
        try {
            if (p != null) {
                p.close();
            }
        } catch (Throwable t) {
            LogTool.w(TAG, "closeSilently. fail to close.", t);
        }
    }

    public static void closeSilently(Cursor c) {
        try {
            if (c != null) {
                c.close();
            }
        } catch (Throwable t) {
            LogTool.w(TAG, "closeSilently. fail to close.", t);
        }
    }
}
